package com.shopping.mall.core.module.ipAddress.mapper;

import com.shopping.mall.core.module.instrumentPanel.entity.HourVisitNum;
import com.shopping.mall.core.module.ipAddress.entity.IpAddress;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.sql.Timestamp;
import java.util.List;

/**
 * <p>
 * IpAddressMapper 接口
 * </p>
 *
 * @author zzy
 * @since 2021-08-30
 */
@Mapper
public interface IpAddressMapper extends BaseMapper<IpAddress> {

    @Select("SELECT DATE_FORMAT( create_at, '%Y-%m-%d %H:00:00' ) as time, COUNT(1) as num \n" +
            "FROM ip_address where create_at>#{time}" +
            "GROUP BY\n" +
            "\ttime \n" +
            "ORDER BY\n" +
            "\ttime")
    List<HourVisitNum> getHourVisitNum(Timestamp time);

}
